package wordroid.widget;

import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.RemoteViews;
import java.util.ArrayList;
import wordroid.activitys.EditWord;
import wordroid.database.DataAccess;
import wordroid.model.Word;

public class Wordroid_Widget extends AppWidgetProvider
{
  static int num = 0;
  static ArrayList<Word> words;
  final String add_action = "ADD";
  final String last_action = "LAST";
  final String next_action = "NEXT";

  public void onReceive(Context paramContext, Intent paramIntent)
  {
    super.onReceive(paramContext, paramIntent);
    DataAccess localDataAccess = new DataAccess(paramContext);
    words = new ArrayList();
    words = localDataAccess.QueryAttention(null, null);
    if (paramIntent.getAction().equals("NEXT"))
    {
      if (num != -1 + words.size())
       // break label201;
      num = 0;
    }
    if (paramIntent.getAction().equals("LAST"))
    {
      label65: if (num != 0)
     //   break label212;
      num = -1 + words.size();
    }
    while (true)
    {
      RemoteViews localRemoteViews = new RemoteViews(paramContext.getPackageName(), 2130903060);
      if (words.size() > 0)
        localRemoteViews.setTextViewText(2131165261, ((Word)words.get(num)).getSpelling() + "\n" + ((Word)words.get(num)).getMeanning());
      ComponentName localComponentName = new ComponentName(paramContext, Wordroid_Widget.class);
      AppWidgetManager.getInstance(paramContext).updateAppWidget(localComponentName, localRemoteViews);
      return;
//      label201: num = 1 + num;
//      break label65:
//      label212: num = -1 + num;
    }
  }

  public void onUpdate(Context paramContext, AppWidgetManager paramAppWidgetManager, int[] paramArrayOfInt)
  {
    super.onUpdate(paramContext, paramAppWidgetManager, paramArrayOfInt);
    RemoteViews localRemoteViews = new RemoteViews(paramContext.getPackageName(), 2130903060);
    Intent localIntent1 = new Intent(paramContext, Wordroid_Widget.class);
    localIntent1.setAction("NEXT");
    localRemoteViews.setOnClickPendingIntent(2131165264, PendingIntent.getBroadcast(paramContext, 0, localIntent1, 0));
    Intent localIntent2 = new Intent(paramContext, Wordroid_Widget.class);
    localIntent2.setAction("LAST");
    localRemoteViews.setOnClickPendingIntent(2131165262, PendingIntent.getBroadcast(paramContext, 0, localIntent2, 0));
    Intent localIntent3 = new Intent(paramContext, EditWord.class);
    Bundle localBundle = new Bundle();
    localBundle.putString("action", "add");
    localIntent3.putExtras(localBundle);
    localRemoteViews.setOnClickPendingIntent(2131165263, PendingIntent.getActivity(paramContext, 0, localIntent3, 0));
    DataAccess localDataAccess = new DataAccess(paramContext);
    words = new ArrayList();
    words = localDataAccess.QueryAttention(null, null);
    if (words.size() > 0)
      localRemoteViews.setTextViewText(2131165261, ((Word)words.get(num)).getSpelling() + "\n" + ((Word)words.get(num)).getMeanning());
    paramAppWidgetManager.updateAppWidget(paramArrayOfInt, localRemoteViews);
  }
}

/* Location:           E:\Desktop\Android\英语词汇记忆\classes_dex2jar.jar
 * Qualified Name:     wordroid.widget.Wordroid_Widget
 * JD-Core Version:    0.5.3
 */